import { Router } from "express";
import { user } from "../../../modules";

const router = Router();

router.post("/", async (req, res: any) => {
  try {
    console.log(req.body);
    const { username, password } = req.body;
    const result = await user.findAll({
      where: {
        username,
        password,
      },
    });
    if (result.length === 1) {
      res.send({
        status: 200,
        message: "Success",
        data: result[0],
      });
    } else {
      res.cc(401, "账号或密码错误，请检查");
    }
  } catch (error: any) {
    res.cc(error.message);
  }
});
export default router;
